package com.fgou.springcloud.service.Dept;

import com.fgou.springcloud.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author 99
 */
@Component
public class DeptClientServiceImpl implements FallbackFactory {


    @Override
    public Object create(Throwable throwable) {
        return new DeptClientService() {
            Dept dept = new Dept().setDeptId(-1L).setDeptName("服务器内部出现错误，导致接口异常").setDbSource(null);

            @Override
            public List<Dept> getDeptAll() {
                ArrayList depots = new ArrayList();
                depots.add(dept);
                return depots;
            }

            @Override
            public Dept getDeptById(Long id) {
                return dept;
            }

            @Override
            public Boolean addDeptOne(Map<String, String> map) {
                return false;
            }
        };
    }
}
